From bf130da741b63c1cdd92969f513aa74258dc3d62 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 15 Dec 2015 21:23:59 +0100 Subject: [PATCH] cssimage: Handle 0x0 images 0x0 images can happen when we fail to load an image - or when we successfully load a 0x0 image. --- gtk/gtkcssimagesurface.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssimagesurface.c b/gtk/gtkcssimagesurface.c index ac812ddcb0..1570e83bed 100644 --- a/gtk/gtkcssimagesurface.c +++ b/gtk/gtkcssimagesurface.c @@ -46,11 +46,18 @@ gtk_css_image_surface_draw (GtkCssImage *image, double height) { GtkCssImageSurface *surface = GTK_CSS_IMAGE_SURFACE (image); + int image_width, image_height; + + image_width = cairo_image_surface_get_width (surface->surface); + image_height = cairo_image_surface_get_height (surface->surface); + + if (image_width == 0 || image_height == 0) + return; cairo_rectangle (cr, 0, 0, width, height); cairo_scale (cr, - width / cairo_image_surface_get_width (surface->surface), - height / cairo_image_surface_get_height (surface->surface)); + width / image_width, + height / image_height); cairo_set_source_surface (cr, surface->surface, 0, 0); cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD); cairo_fill (cr); -- 2.30.2